package com.itheima.d4_create_thread;

/**
 * 目标：掌握多线程的创建方式二：实现Runnable接口。
 */
public class ThreadTest2 {
    public static void main(String[] args) {
        Thread t1 = new Thread(new MyRunnable("小绿"));
        t1.start();
        new Thread(new MyRunnable("小黄")).start();
        new Thread(new MyRunnable("小粉")).start();

        //lambda方式
        new Thread(() ->System.out.println("我是lambda方式实现!!!")).start();

        //匿名内部类
        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("我是匿名内部类!!");
            }
        });

    }

}
class MyRunnable implements Runnable{

    private  String name;

    public MyRunnable() {
    }

    public MyRunnable(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(name+i);
        }
    }
}
